#include <iostream>
using namespace std;

const int N = 20000 + 10;
int st[N];
int primes[N];
int cnt;

void get_primes(int x) {
    for (int i = 2; i <= x; i++) {
        if (!st[i]) {
            primes[cnt++] = i;
        }
        for (int j = 0; primes[j] <= x / i; j++) {
            st[primes[j] * i] = true;
            if (i % primes[j] == 0) break;
        }
    }
}

int main() {
    int n = 20000;
    get_primes(n);

    for (int i = 0; i < cnt; i++) {
        cout << primes[i] << " ";
        if ((i + 1) % 5 == 0) {
            cout << endl;
        }
    }

    return 0;
}

